/*
 *  This file is part of Spidex.
 *  
 *  Spidex is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Spidex is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Spidex.  If not, see <http://www.gnu.org/licenses/>.
 */

package spidex.dbmanager;

/**
 *
 * @author xatrix
 */
public class DBCondition {
    private ConditionType type;
    private Object obj;
    private final boolean isNumber;
    private final String dbName;
    private String strArg;
    private int intArg;

    
    public DBCondition(ConditionType type, String arg) {
        if(arg == null) {
            throw new NullPointerException("object");
        }

        this.isNumber = type.isNumber();
        this.dbName = type.getDbName();
        
        if( type.isNumber()  ) {
            throw new IllegalArgumentException("object");
        }
        this.strArg = arg;
    }
    
    public DBCondition(ConditionType type, int arg) {
        this.isNumber = type.isNumber();
        this.dbName = type.getDbName();
        
        if( !type.isNumber()  ) {
            throw new IllegalArgumentException("object");
        }
        this.intArg = arg;
    }
    
    public boolean isNumber() {
        return this.isNumber;
    }
    
    public String getDbName() {
        return this.dbName;
    }
    
    public int getInt() {
        return this.intArg;
    }
    
    public String getString() {
        return this.strArg;
    }
  
    public class DBConditionException extends Exception {

        public DBConditionException() {
            super();
        }
        
        public DBConditionException(String mes) {
            super(mes);
        }
        
        public DBConditionException(Throwable thr) {
            super(thr);
        }
        
        public DBConditionException(String mes, Throwable thr) {
            super(mes, thr);
        }
    }
            
}
